#pragma once
#include <iostream>
#include <map>
#include <functional>
#include <algorithm>
#include "calculator.h"

using namespace std;


void test1()
{
	typedef std::function<int(int, int)> AlgorithmFunction;

	std::map<char, AlgorithmFunction> AlgorithmMap;
	AlgorithmMap.insert({ '+',[](int x,int y) {return x + y;} });
	AlgorithmMap.insert({ '-',[](int x,int y) {return x - y;} });
	AlgorithmMap.insert({ '*',[](int x,int y) {return x * y;} });
	AlgorithmMap.insert({ '/',[](int x,int y) {return x / y;} });
	AlgorithmMap.insert({ '%',[](int x,int y) {return x % y;} });

	int a = 8, b = 2;

	int record = AlgorithmMap['+'](a, b);
	cout << record << endl;
	record = AlgorithmMap['-'](a, b);
	cout << record << endl;
	record = AlgorithmMap['*'](a, b);
	cout << record << endl;
	record = AlgorithmMap['/'](a, b);
	cout << record << endl;
	record = AlgorithmMap['%'](a, b);
	cout << record << endl;

	record = AlgorithmMap['+'](a, b);
}

void test2()
{
	std::string str1 = " -1*22--3 *(3+ 4)-5";
	std::string str2;
	str2 = MyCalculator::ToArithmeticStr(str1);
	for (auto it : str2)
	{
		std::cout << it;
	}
	std::cout << std::endl;
	std::vector<std::string> vector_str;
	int num = 0;
	MyCalculator::InfixToSuffix(vector_str, str2, num);
	for (auto it : vector_str)
	{
		std::cout << it;
	}
	std::cout << std::endl;
	int num2 = MyCalculator::SuffixArithmetic(vector_str);
	std::cout << num2 << std::endl;

	std::string str = "2 1*2 187 -88 /8+1 2*2 2*1 3+2";
	//std::cin >> str;
	int num3 = MyCalculator::OperationsCalculation(str);
	std::cout << num3 << std::endl;
}

int main()
{
	test2();
	return 0;
}